from sqlalchemy import create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import sessionmaker

from util.yaml_util import load_yaml_config

# 从配置文件中获取数据库 URL
DATABASE_URL = load_yaml_config('config/mysql.yaml', 'database', 'url')

# 创建数据库引擎
engine = create_engine(DATABASE_URL)

# 创建会话工厂
SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)

# 声明基类
Base = declarative_base()
